package com.sevenGroup.pawnshop.controller;


import com.sevenGroup.pawnshop.Utils.Result;
import com.sevenGroup.pawnshop.controller.info.FunctionInfo;
import com.sevenGroup.pawnshop.model.FirstType;
import com.sevenGroup.pawnshop.service.FunctionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author sevenGroup
 * @since 2022-02-16
 */
@RestController
@RequestMapping("/function")
@Api(tags = "功能相同：查询功能")
public class FunctionController {
    @Resource
    private FunctionService functionService;
//    通过角色ID查询功能集合
    @ApiOperation("查询某个角色所拥有的功能")
    @PostMapping("getFunctionByRoleId")
    @PreAuthorize("hasAnyAuthority('boss','shopManage','worker','noWorker')")
    public Result getFunctionByRoleId(@ApiParam("传入角色ID") Integer rid){
        List<FunctionInfo> functionInfos=functionService.getFunctionByRoleId(rid);
        return Result.success(functionInfos);
    }

}

